package top.v5it.japi.plus.common.tuple;

import lombok.EqualsAndHashCode;
import lombok.Getter;

/**
 * 二元组
 *
 * @author zhanpu
 * @date 2022/6/18
 */
@Getter
@EqualsAndHashCode(callSuper = false)
public class Tuple2<T1, T2> extends Tuple1<T1> {

    private static final long serialVersionUID = -786208108849160561L;
    final T2 two;

    Tuple2(T1 one, T2 two) {
        super(one);
        this.two = two;
    }

    @Override
    public Object[] toArray() {
        return new Object[]{this.one, this.two};
    }

    @Override
    public int size() {
        return 2;
    }

    @Override
    public Object get(int index) {
        switch (index) {
            case 0:
                return this.one;
            case 1:
                return this.two;
            default:
                return null;
        }
    }

}
